/* 分块
* 1.解题思路 懒标记
    add:本段中的所有数都要加上add
    sum:本段的真实和是多少(算上add)

* 2.op
    [(段内) (完整段) (段内)]
    修改：
        完整段(<=sqrt(n)) add=add+d
                          sum=sum+d+length
        段内 暴力 枚举所有数 w[i]=w[i]+d
                           sum=sum+d;

    查询：
        完整段(<=sqrt(n)) 累加sum
        段内 暴力 枚举所有数 求和

*/
#define DEBUG
#pragma GCC optimize("O1,O2,O3,Ofast")
#pragma GCC optimize("no-stack-protector,unroll-loops,fast-math,inline")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,ssse3")

#include <cstdio>
#include <cmath>
// #define int long long
using ll=long long;
using namespace std;

inline int read(){
	int x=0;
	bool f=0;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+c-48;
		c=getchar();
	}
	return f?-x:x;
}

const int N = 100010, M=350;

int len;
ll add[M], sum[M];
int w[N];

inline int get(int x) //x所在块
{
    return x/len;
}

inline void modify(int l, int r, int d) //区间修改
{
    if(get(l)==get(r)) //l和r在同一块内
    {
        for(int i=l; i<=r; i++)
            w[i]+=d, sum[get(l)]+=d; //块内: sum数量*d
        return;
    }
    int i=l, j=r;
    while(get(i)==get(l)) //在左侧块
        w[i]+=d, sum[get(l)]+=d, i++;
    while(get(j)==get(r)) //在右侧块
        w[j]+=d, sum[get(r)]+=d, j--;
    for(int k=get(i); k<=get(j); k++) //中间块
        sum[k]+=d*len, add[k]+=d;
}

inline ll query(int l, int r) //区间求和
{
    ll res=0;
    //printf("l:%lld r:%lld getl:%lld getr:%lld\n", l, r, get(l), get(r));

    if(get(l)==get(r))
    {
        for(int i=l; i<=r; i++)
            res+=w[i]+add[get(l)];//, printf("res:%d i:%d\n", res, i);
        return res;
    }

    int i=l, j=r;
    while(get(i)==get(l)) //在左侧块
        res+=w[i]+add[get(l)], i++;
    while(get(j)==get(r)) //在右侧块
        res+=w[j]+add[get(r)], j--;
    for(int k=get(i); k<=get(j); k++) //中间块
        res+=sum[k];
    return res;
}

signed main()
{

    #ifdef DEBUG
        freopen("./in.txt","r",stdin);
        freopen("./out.txt","w",stdout);
    #endif
    int n, m;
    scanf("%d%d", &n, &m);
    len=sqrt(n); //块的长度
    for(int i=1; i<=n; i++)
            scanf("%d", &w[i]), sum[get(i)]+=w[i];
    while(m--){
        char op[2]; int l, r, d;
        scanf("%s%d%d", op, &l, &r);
        //printf("op:%s l:%lld r:%lld\n", op, l, r);
        if(*op == 'C'){
            scanf("%d", &d);
            modify(l, r, d);
        }
        else if(*op == 'Q'){
            printf("%lld\n", query(l, r));
        }
    }
    return 0;
}
